package com.first.course.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.EduCourse;
import com.first.common.vo.Result;
import com.first.course.service.EduCourseService;
import com.first.course.vo.EduCourseVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: first-project
 * @description:
 * @author: 路志欣
 * @create: 2023-05-26 15:52
 **/
@RestController
@RequestMapping("/cours/course")
public class EduCourseController {
    @Autowired
    private EduCourseService eduCourseService;

    @PostMapping("/findCourse/{pageCurrent}/{pageSize}")
    @ApiOperation(value = "分页模糊查询")
    private Result findCourse(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody EduCourseVo eduCourseVo){
        Page<EduCourse> course = eduCourseService.findCourse(pageCurrent, pageSize, eduCourseVo);
        return Result.success(course);
    }

    @PostMapping("/changeStatus/{id}/{status}")
    @ApiOperation(value = "修改状态")
    private Result changeStatus(@PathVariable String id,@PathVariable String status){
        Integer integer = eduCourseService.updateStatus(id, status);
        return Result.success();
    }

    @PostMapping("/updateCourse")
    @ApiOperation(value = "修改表单")
    private Result updateCourse(@RequestBody EduCourse eduCourse){
        Integer integer = eduCourseService.updateCourseDescription(eduCourse);
        return Result.success();
    }

}